package com.egene.zh.activity.member;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.egene.zh.R;
import com.egene.zh.api.EgeneApi;
import com.egene.zh.base.BaseActivity;
import com.egene.zh.dao.UserDao;
import com.egene.zh.model.MoreDetail;
import com.egene.zh.utils.JsonUtil;
import com.loopj.android.http.AsyncHttpResponseHandler;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;
import org.apache.http.Header;

@EActivity(R.layout.activity_more_detail)
public class MoreDetailActivity extends BaseActivity {
    //ToolBar Views
    @ViewById(R.id.actionBar)
    Toolbar mToolbarView;
    @ViewById(R.id.toolbar_title)
    TextView mToolBarTitle;

    @ViewById(R.id.tvDesc)
    TextView tvDesc;
    @ViewById(R.id.tvDesc1)
    TextView tvDesc1;


    @Extra
    String rid;
    @Extra
    String orderId;

    @Bean
    UserDao userDao;

    @AfterViews
    void initViews(){
        initToolBar();

        EgeneApi.getMoreDetail(userDao.getUser().getUserID(), rid,orderId, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                MoreDetail result = JsonUtil.parse(responseBody, MoreDetail.class);
                if(result != null){
                    tvDesc.setText(result.getRiskRemark());
                    tvDesc1.setText(result.getCareRemark());
                }

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
//                System.out.println(new String(responseBody));
            }
        });


    }


    private void initToolBar() {
        mToolBarTitle.setText(R.string.detail);
        mToolbarView.setNavigationIcon(R.drawable.ic_back);
        mToolbarView.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}
